package bottle.jack;
import org.json.JSONObject;

import com.google.code.morphia.annotations.Embedded;
import com.google.code.morphia.annotations.Id;


public class Annotation {

	@Id String id;
	@Embedded
	Content content;
	@Embedded
	User poster;
	@Embedded
	Location location;
	public Annotation(User poster, TextContent content)
	{
		this.poster = poster;
		this.content = content;
		location = poster.location;
	}
	/**
	 * Converts the annotation to JSON.
	 * @return the JSON of the annotation.
	 */
  public final JSONObject toJSON() {
    JSONObject annotationJson = new JSONObject();
    annotationJson.put("id", id);
    annotationJson.put("messageData", content.text);
    annotationJson.put("name", poster.nickname);
    annotationJson.put("latitude", location.latitude);
    annotationJson.put("longitude", location.longitude);
    annotationJson.put("accuracy", location.accuracy);
    annotationJson.put("date", location.date);
    return annotationJson;
  }
}
